package cn.icanci.loopstack.amc.sample.service;

import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

import javax.annotation.Resource;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;

import com.google.common.collect.Sets;

/**
 * @author icanci
 * @since 1.0 Created in 2023/01/17 10:47
 */
@Service
@SuppressWarnings("all")
public class TriggerService implements InitializingBean {

    @Resource
    private MockCallService          mockCallService;

    private static final Set<String> MOCK_UUID = Sets.newHashSet("AMC1614866122736828416", "AMC1615305165685792768", "AMC1615303914512326656", "AMC1615303191225573376");

    @Override
    public void afterPropertiesSet() throws Exception {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        for (String s : MOCK_UUID) {
//                            MockCallUtils.doMockCall()
                            mockCallService.testMockCall(s);
                        }
                        LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(10));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        });
        thread.start();
        thread.setDaemon(true);
    }
}
